using System.Threading.Tasks;
using Matrix.Configuration.Events;

namespace Matrix.Configuration.Services
{
    /// <summary>
    /// 配置事件分发器接口
    /// 负责智能选择本地事件或分布式事件进行配置变更通知
    /// </summary>
    public interface IConfigurationEventDistributor
    {
        /// <summary>
        /// 发布配置变更事件
        /// </summary>
        /// <param name="eventData">配置变更事件数据</param>
        Task PublishConfigurationChangedAsync(ConfigurationChangedEto eventData);

        /// <summary>
        /// 发布批量配置变更事件
        /// </summary>
        /// <param name="batchEventData">批量配置变更事件数据</param>
        Task PublishConfigurationBatchChangedAsync(ConfigurationBatchChangedEto batchEventData);

        /// <summary>
        /// 发布配置缓存失效事件
        /// </summary>
        /// <param name="cacheKeys">缓存键列表</param>
        /// <param name="configurationKey">配置键</param>
        /// <param name="namespace">配置命名空间</param>
        /// <param name="reason">失效原因</param>
        /// <param name="isDistributedCache">是否为分布式缓存</param>
        /// <param name="tenantId">租户ID</param>
        Task PublishCacheInvalidatedAsync(
            System.Collections.Generic.List<string> cacheKeys,
            string configurationKey,
            string @namespace,
            string reason,
            bool isDistributedCache = false,
            System.Guid? tenantId = null);

        /// <summary>
        /// 发布配置验证事件
        /// </summary>
        /// <param name="key">配置键</param>
        /// <param name="namespace">配置命名空间</param>
        /// <param name="value">配置值</param>
        /// <param name="valueType">值类型</param>
        /// <param name="validationResult">验证结果</param>
        /// <param name="triggeredBy">验证触发者</param>
        /// <param name="tenantId">租户ID</param>
        Task PublishValidationEventAsync(
            string key,
            string @namespace,
            string? value,
            string valueType,
            ConfigurationValidationResult validationResult,
            string triggeredBy,
            System.Guid? tenantId = null);
    }
}